rm(list = ls())
set.seed(2074530682)
require(AER)
require(RItools)
d.kn <- read.csv('dat/study1.csv', stringsAsFactors = FALSE)
d.yg <- read.csv('dat/study2.csv', stringsAsFactors = FALSE)
B <- 10000
cat('Note: Bootstraps are set to', B, 'replicates.\n')
source('functions.R')
source('data_prep_study1.R')
source('data_prep_study2.R')
source('balance.R')

# main analysis
# resulting objects are named...
source('CACE_study1.R')           # CACE_S1_<OUTCOME>
source('CACE_study2.R')           # CACE_S2_<OUTCOME>
source('ITT_study1.R')            # ITT_S1_<OUTCOME>
source('ITT_study2.R')            # ITT_S2_<OUTCOME>
source('heterogeneity.R')         # loo_<OUTCOME>
source('ipw_CACE_study1.R')       # IPW_CACE_S1_<OUTCOME>
source('ipw_CACE_study2.R')       # IPW_CACE_S2_<OUTCOME>
source('complier_reporter.R')     # tableS2, tableS7
source('bounds.R')                # boundsS1, boundsS2
source('copartisanship_study1.R') # Copartisan_CACE_S1_<OUTCOME>
source('copartisanship_study2.R') # Copartisan_CACE_S2_<OUTCOME>

# reporting
source('print_main.R')
source('print_supporting_info.R')
source('draw_figure_2.R')
source('draw_figure_3.R')
source('draw_figure_4.R')